package com.ymatou.iapi.productmanager.testcase;

import com.ymatou.iapi.productmanager.parameter.SaleCommissionDto;
import com.ymatou.iapi.productmanager.parameter.UpdateCatalogCommisionsBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productmanager.service.UpdateCatalogCommisionsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.business.service.ProductManagerCallServiceV3;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.EnvSetup;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
*批量更改销售佣金
*FreeMaker Template自动生成代码
*/
@TestSuite
@Ignore
//优选商品下架
public class Ts_UpdateCatalogCommisions{
	private static UpdateCatalogCommisionsBean updatecatalogcommisionsBean;
	private static UpdateCatalogCommisionsCall updatecatalogcommisionsCall;
	private static int sellerId = Integer.parseInt(EnvSetup.getData("globalSellerId"));
	//免税店
	public static int userId=AgentUsers.vipRootUserId;
	public static String userName="韩国免税店";
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量更改销售佣金");
	}

	@Before
	public void caseUp() {
		updatecatalogcommisionsBean=new UpdateCatalogCommisionsBean();
		updatecatalogcommisionsCall=new UpdateCatalogCommisionsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatecatalogcommisionsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_001() {	
		Logger.start(true,"批量更改销售佣金,单规格，优选团商品");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist =  new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto.setCatalogId(catalogslist.get(0).getsCatalogId());
			saleCommissionDto.setSaleCommission(new BigDecimal("0.07"));
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			YmtCatalogsI catalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals("0.0700",catalogsI.getSaleCommissionPercent(),"验证SaleCommissions");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_002() {
		Logger.start(true,"批量更改销售佣金,多规格，礼包商品");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto1 = new SaleCommissionDto();
			SaleCommissionDto saleCommissionDto2 = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist =  new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto1.setCatalogId(catalogslist.get(0).getsCatalogId());
			saleCommissionDto2.setCatalogId(catalogslist.get(1).getsCatalogId());
			BigDecimal saleCommission1 = new BigDecimal(0.05);
			BigDecimal saleCommission2 = new BigDecimal(0.06);
			BigDecimal saleCommission3 = new BigDecimal(0.07);
			BigDecimal saleCommission4 = new BigDecimal(0.08);
			ArrayList<BigDecimal> salecommissionList = new ArrayList<BigDecimal>();
			salecommissionList.add(saleCommission1);
			salecommissionList.add(saleCommission2);
			salecommissionList.add(saleCommission3);
			salecommissionList.add(saleCommission4);
			saleCommissionDto1.setSaleCommissionList(salecommissionList);
			saleCommissionDto2.setSaleCommissionList(salecommissionList);
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto1,saleCommissionDto2));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			YmtCatalogsI catalogsI1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			YmtCatalogsI catalogsI2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(1).getsCatalogId());
			Logger.verifyEquals(saleCommission1.intValue(),catalogsI1.getSaleCommission().intValue(),"验证销售佣金1");
			Logger.verifyEquals(saleCommission2.intValue(),catalogsI2.getSaleCommission().intValue(),"验证销售佣金2");

			saleCommission1 = new BigDecimal(0.1);
			saleCommission2 = new BigDecimal(0.08);
			saleCommissionDto1.setSaleCommission(saleCommission1);
			saleCommissionDto2.setSaleCommission(saleCommission2);
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto1,saleCommissionDto2));
			updatecatalogcommisionsCall.callService();
			catalogsI1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			catalogsI2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(1).getsCatalogId());
			Logger.verifyEquals(saleCommission1.intValue(),catalogsI1.getSaleCommission().intValue(),"验证销售佣金1");
			Logger.verifyEquals(saleCommission2.intValue(),catalogsI2.getSaleCommission().intValue(),"验证销售佣金2");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_003() {
		Logger.start(true,"批量更改销售佣金,销售佣金不得高于含税价");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist =  new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto.setCatalogId(catalogslist.get(0).getsCatalogId());
			BigDecimal saleCommission = new BigDecimal(0.05);
			saleCommissionDto.setSaleCommission(saleCommission);
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			YmtCatalogsI catalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals(saleCommission.intValue(),catalogsI.getSaleCommission().intValue(),"验证销售佣金");
			BigDecimal saleCommission1 = new BigDecimal(1000);
			saleCommissionDto.setSaleCommission(saleCommission1);
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.callService();
			catalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			Logger.verifyEquals(saleCommission.intValue(),catalogsI.getSaleCommission().intValue(),"验证销售佣金");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_004() {
		Logger.start(true,"批量更改销售佣金,销售佣金规格不存在");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist =  new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto.setCatalogId(catalogslist.get(0).getsCatalogId());
			BigDecimal saleCommission = new BigDecimal("0.0500");
			saleCommissionDto.setSaleCommission(saleCommission);
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			YmtCatalogsI catalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals(saleCommission.intValue(),catalogsI.getSaleCommission().intValue(),"验证销售佣金");
			BigDecimal saleCommission1 = new BigDecimal("0.1000");
			saleCommissionDto.setSaleCommission(saleCommission1);
			//规格不存在
			saleCommissionDto.setCatalogId("adadadasd");
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.callService();
			catalogsI = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogslist.get(0).getsCatalogId());
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			Logger.verifyEquals(saleCommission.intValue(),catalogsI.getSaleCommission().intValue(),"验证销售佣金");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_005() {
		Logger.start(true,"批量更改销售佣金,佣金为负数");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());
			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			List<YmtCatalogsI> catalogslist =  new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			saleCommissionDto.setCatalogId(catalogslist.get(0).getsCatalogId());
			BigDecimal saleCommission = new BigDecimal("-5.00");
			saleCommissionDto.setSaleCommission(saleCommission);
			
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UpdateCatalogCommisions_006() {
		Logger.start(true,"批量更改销售佣金,优选团商品,多规格   //优选团商品取消多规格 wiki：pageId=28313070");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);
			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.0600"));
			saleCommissionList.add(new BigDecimal("0.0700"));
			saleCommissionList.add(new BigDecimal("0.0800"));
			saleCommissionList.add(new BigDecimal("0.0900"));
			String saleCommissions = "0.0600,0.0700,0.0800,0.0900";

			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(sellerId,productId,catalogId1,addSellerProductRequest.getSellerName(),saleCommissionList);
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(sellerId,productId,catalogId2,addSellerProductRequest.getSellerName(),saleCommissionList);

			
			YmtCatalogsI ymtCatalogsI1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogId1);
			YmtCatalogsI ymtCatalogsI2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogId2);
			System.out.println(ymtCatalogsI1.toString());
			Logger.verifyEquals(saleCommissions,ymtCatalogsI1.getSaleCommissionPercent(),"验证SaleCommissionPercent");
			Logger.verifyEquals("0.0800",ymtCatalogsI2.getSaleCommissionPercent(),"验证SaleCommissionPercent");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_010() {
		Logger.start(true,"批量更改销售佣金,礼包商品,多规格");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.0600"));
			saleCommissionList.add(new BigDecimal("0.0700"));
			saleCommissionList.add(new BigDecimal("0.0800"));
			saleCommissionList.add(new BigDecimal("0.0900"));
			String saleCommissions = "0.0600,0.0700,0.0800,0.0900";

			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(sellerId,productId,catalogId1,addSellerProductRequest.getSellerName(),saleCommissionList);
			ProductManagerCallServiceV2.UpdateCatalogCommisionsV2(sellerId,productId,catalogId2,addSellerProductRequest.getSellerName(),saleCommissionList);

			
			YmtCatalogsI ymtCatalogsI1 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogId1);
			YmtCatalogsI ymtCatalogsI2 = new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogId2);
			System.out.println(ymtCatalogsI1.toString());
			Logger.verifyEquals(saleCommissions,ymtCatalogsI1.getSaleCommissionPercent(),"验证SaleCommissionPercent");
			Logger.verifyEquals(saleCommissions,ymtCatalogsI2.getSaleCommissionPercent(),"验证SaleCommissionPercent");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_0101() {
		Logger.start(true,"批量更改销售佣金,礼包商品,佣金比上一级低，更改失败");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.08"));
			saleCommissionList.add(new BigDecimal("0.07"));
			saleCommissionList.add(new BigDecimal("0.04"));
			saleCommissionList.add(new BigDecimal("0.09"));
			updatecatalogcommisionsBean.setUserId(sellerId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setProductId(productId);

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();

			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UpdateCatalogCommisions_0102() {
		Logger.start(true,"批量更改销售佣金,优选团商品,佣金比上一级低，更改失败    //优选团商品取消多规格 wiki：pageId=28313070");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.09"));
			saleCommissionList.add(new BigDecimal("0.02"));
			saleCommissionList.add(new BigDecimal("0.08"));
			saleCommissionList.add(new BigDecimal("0.09"));

			updatecatalogcommisionsBean.setUserId(sellerId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setProductId(productId);

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);
			saleCommissionDto.setSaleCommission(new BigDecimal("0.8"));

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();

			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UpdateCatalogCommisions_007() {
		Logger.start(true,"批量更改销售佣金,优选团商品,销售佣金个数不正确    //优选团商品取消多规格 wiki：pageId=28313070");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.06"));
			saleCommissionList.add(new BigDecimal("0.07"));

			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);
//			saleCommissionDto.setSaleCommission(new BigDecimal("0.07"));

			
			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_00701() {
		Logger.start(true,"批量更改销售佣金,礼包商品,销售佣金个数不正确");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.06"));
			saleCommissionList.add(new BigDecimal("0.07"));

			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_008() {
		Logger.start(true,"批量更改销售佣金,优选团商品,销售佣金小于0");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();


			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommission(new BigDecimal("-3.00"));
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_00901() {
		Logger.start(true,"批量更改销售佣金,礼包商品,销售佣金小于0");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.06"));
			saleCommissionList.add(new BigDecimal("-3"));
			saleCommissionList.add(new BigDecimal("0.07"));
			saleCommissionList.add(new BigDecimal("0.07"));

			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_009() {
		Logger.start(true,"批量更改销售佣金,优选团商品,销售佣金高于含税价");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();


			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommission(new BigDecimal("1.0600"));
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateCatalogCommisions_011() {
		Logger.start(true,"批量更改销售佣金,礼包商品,销售佣金高于含税价");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);

			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();
			String catalogId2 = ymtCatalogsIList.get(1).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.06"));
			saleCommissionList.add(new BigDecimal("0.07"));
			saleCommissionList.add(new BigDecimal("0.999"));
			saleCommissionList.add(new BigDecimal("2"));

			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			Logger.verifyEquals("201",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
		
		
		
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_UpdateCatalogCommisions_012() {
		Logger.start(true,"礼包商品升级为优选商品,查看佣金列表是多个还是一个");
		try {
			AddSellerProductRequest addSellerProductRequest =  ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addSellerProductRequest).get("Data").getAsJsonObject().get("ProductId").getAsString();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,1);
			
			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId1 = ymtCatalogsIList.get(0).getsCatalogId();

			List<BigDecimal> saleCommissionList = new ArrayList<>();
			saleCommissionList.add(new BigDecimal("0.06"));
			saleCommissionList.add(new BigDecimal("0.07"));
			saleCommissionList.add(new BigDecimal("0.08"));
			saleCommissionList.add(new BigDecimal("0.09"));
			updatecatalogcommisionsBean.setProductId(productId);
			updatecatalogcommisionsBean.setSellerName(addSellerProductRequest.getSellerName());
			updatecatalogcommisionsBean.setUserId(addSellerProductRequest.getSellerId());

			SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
			saleCommissionDto.setSaleCommissionList(saleCommissionList);
			saleCommissionDto.setCatalogId(catalogId1);

			updatecatalogcommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
			updatecatalogcommisionsCall.setData(updatecatalogcommisionsBean);
			updatecatalogcommisionsCall.callService();
			ProductManagerCallServiceV2.AddSellerGlobalPspProduct(sellerId,productId,2);
			List<YmtCatalogsI> ymtCatalogsIList1 = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			String catalogId11 = ymtCatalogsIList1.get(0).getsCatalogId();;
			System.out.println(ymtCatalogsIList1.get(0));
//			String saleCommissions = catalogsI1.getSaleCommissions();
//			BigDecimal saleCommission = catalogsI1.getSaleCommission();
			
//			System.out.println(saleCommissions);
//			System.out.println(saleCommission);
			Logger.verifyEquals("200",updatecatalogcommisionsCall.getString("Code"),"验证Code");
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}